Fix GH-22422: define ZEND_TRACK_ARENA_ALLOC in php_config.h#22439
Merged
iliaal merged 1 commit intoJun 24, 2026
Conversation
ZEND_TRACK_ARENA_ALLOC selects an alternative zend_arena struct layout for AddressSanitizer, but it was only appended to the core CFLAGS, never recorded in php_config.h. Extensions built separately with phpize inherit php_config.h rather than the core CFLAGS, so they compiled the untracked layout while core used the tracked one. Destroying a core-created arena from such an extension leaked every tracked allocation. Define it with AC_DEFINE so core and extensions agree on the layout. Fixes phpGH-22422
TimWolla
approved these changes
Jun 24, 2026
TimWolla
left a comment
Member
There was a problem hiding this comment.
Not an expert regarding this part of the engine, but the reasoning seems sound, I'm not seeing obvious issues in the diff and trying to build against mismatching struct layouts is surely going to cause issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ZEND_TRACK_ARENA_ALLOC switches the zend_arena struct layout under AddressSanitizer but was only added to the core CFLAGS, so it never reached php_config.h. A phpize-built extension inherits php_config.h, not the core CFLAGS, and therefore compiled the untracked layout while core used the tracked one; calling zend_arena_destroy on a core-created arena from such an extension leaked every tracked allocation (78 leaks reproduced via zend_test_compile_to_ast). AC_DEFINE it so the layout stays consistent across core and separately built extensions.
Fixes #22422